package com.heima.string.practice;

public class Demo02 {
    public static void main(String[] args) {
        /**
         * 调整字符串
         * 给定两个字符串A和B
         * A的旋转操作就是将A最左边的字符移动到最右边
         * 如果若干次调整后, A能变成B, 则返回true, 反之返回false
         */
        String a = "abcde";
        String b = "cdeae";

        boolean flag = false;
        for (int i = 1; i < a.length(); i++) {

            char[] chars = a.toCharArray();
            char ch = chars[0];
            for (int j = 1; j < chars.length; j++) {
                chars[j-1] = chars[j];
            }
            chars[chars.length-1] = ch;
            a = new String(chars);

            if(a.equals(b)){
                flag = true;
                System.out.println("Yeah!");
                break;
            }
        }

        if(!flag){
            System.out.println("Noo!");
        }
    }
}
